package com.wd.tech.Base;

import android.content.Context;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.wd.tech.contracts.Contract;

/**
 * date:2020/7/2
 * author:王成虎(13671)
 * month:七月
 * function:
 */
public abstract class BaseActivity <P extends BasePresenter> extends AppCompatActivity implements Contract.IView  {

    public P mPresenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(initLaout());
        initViews();
        //添加沉浸式
        if (getSupportActionBar()!=null){
            getSupportActionBar().hide();
        }
        mPresenter=initPresenter();
        //绑定视图
        if (mPresenter!=null){
            mPresenter.onBulde(this);
        }
        initData();
    }

    protected abstract void initData();

    protected abstract P initPresenter();

    protected abstract void initViews();

    protected abstract int initLaout();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mPresenter.onDetry();
    }

}
